(function (factory) {
    if (typeof define == "function" && define.amd) {
        define([], factory());
    }
    factory();
})(function () {
    var $ = function(tag){
        if(tag.indexOf("#") === 0){
            return document.getElementById(tag.slice(1));
        }else{
            return document.createElement(tag);
        }
    }
    var Carousel = function (opts) {
        return new Carousel.fn.init(opts);
    };

    _prototype = function () {
        var liBox = [],
            _default = {
                imgBoxId: "",
                imgUrl: [],
            },
            hold = false,
            uninit = true,
            interval = null,
            _autoPlay = function () {
                X.each(liBox, function (i, li) {
                    (function (i) {
                        interval = setInterval(function () {

                        }, 20)
                    })(i);
                });
            },
            _bindEvent = function () {

            },
            _createBone = function () {
                var uls = [];
                for (var i = 0; i < 2; i++) {
                    uls.push($("ul"));
                    for (var j = 0; j < this.imgUrl.length; j++) {
                        var li = $("li");
                        li.innerHTML = i == 0 ? this.imgUrl[j] : j;
                        liBox.push(li);
                        uls[i].appendChild(li);
                    }
                    $(_default.imgBoxId).appendChild(uls[i]);
                }
            };
        return {

            init: function (opts) {
                mix(_default, opts);
                if (_default.imgUrl && _default.imgUrl.length > 0) {
                    _createBone();
                    uninit = false;
                    if (hold) {
                        hold = false;
                        this.action();
                    }
                } else {
                    throw new Error("imgUrl 需要为数组");
                }


            },
            action: function () {
                if (uninit) {
                    hold = true;
                    return;
                }
                _bindEvent();
                _autoPlay();
            }
        }
    };
    Carousel.fn = Carousel.prototype = _prototype();
    Carousel.fn.init.prototype = Carousel.fn;
    return window.Carousel = Carousel;
});